<style>
.myDiv {
  border: 5px outset red;
  background-color: lightblue;
  text-align: center;
}
</style>
<body>
<title>post online test</title>
<h1>post online test</h1>
<style>
.td{width:600px}
.text{width:100%;height:200px}
</style>
  <div id="list"></div>
	<script LANGUAGE="JAVASCRIPT">
    let text="";
    var i = 0;
    const ifas = [];
    ifas[i++] = ["forum_select",
      "http://0.0.0.0:16666/ts/forum/select",
      "<root>\n" +
      "\t<child name='ss'>\n" +
      "</root>",
          "<{\"version\":\"1.0.0\",\"class\":\"forum_test\",\"username\":\"3\",\"token\":\"33\"}",
          "{\"data\":[[\"id\",\"username\",\"title\",\"details\",\"time\"],[\"1\",\"test1221\",\"j\",\"jk\",\"jjjj\"]],\"cmd\":\"select * from forum_test;\"}",
      "{\"data\":[]}"];
    ifas[i++] = ["mutation_control_select",
          "http://0.0.0.0:16666/ts/sql/mutation_control_select", "",
          "{\"data\":[{\"id\":\"11\",\"describe\":\"室内四合一噪声\",\"value\":\"53.1\",\"min_control\":\"2\",\"max_control\":\"3\",\"range_control\":\"33\",\"outside_control\":\"32\"},{\"id\":\"137\",\"describe\":\"湿度\",\"value\":\"39.1\",\"min_control\":\"20\",\"max_control\":\"80\",\"range_control\":\"42\",\"outside_control\":\"43\"}]}",
      "{\"data\":[]}"];
    ifas[i++] = ["status_control_delete",
      "http://0.0.0.0:16666/ts/sql/status_control_delete",
      "{\"version\":\"1.0.0\",\"data\":[{\"id\":\"11\"},{\"id\":\"65\"}]}",
      "{\"data\":[]}"];
    ifas[i++] = ["status_control_update",
          "http://0.0.0.0:16666/ts/sql/status_control_update",
          "{\"data\":[{\"id\":\"11\",\"open\":\"2\",\"close\":\"3\"},{\"id\":\"137\",\"open\":\"42\",\"close\":\"43\"}]}",
      "{\"data\":[]}"];
    ifas[i++] = ["status_control_select",
          "http://0.0.0.0:16666/ts/sql/status_control_select", "",
          "{\"data\":[{\"id\":\"11\",\"describe\":\"室内四合一噪声\",\"value\":\"53.1\",\"open\":\"2\",\"close\":\"3\"},{\"id\":\"137\",\"describe\":\"湿度\",\"value\":\"39.1\",\"open\":\"42\",\"close\":\"43\"}]}",
      "{\"data\":[]}"];
    ifas[i++] = ["warn_delete",
      "http://0.0.0.0:16666/ts/sql/warn_delete",
      "{\"version\":\"1.0.0\",\"data\":[{\"id\":\"11\"},{\"id\":\"65\"}]}",
      "{\"data\":[]}"];
    ifas[i++] = ["warn_update",
          "http://0.0.0.0:16666/ts/sql/warn_update",
          "{\"data\":[{\"id\":\"11\",\"min_warn\":\"2\",\"max_warn\":\"3\"},{\"id\":\"137\",\"min_warn\":\"42\",\"max_warn\":\"43\"}]}",
      "{\"data\":[]}"];
    ifas[i++] = ["warn_select",
          "http://0.0.0.0:16666/ts/sql/warn_select", "",
          "{\"data\":[{\"id\":\"11\",\"describe\":\"室内四合一噪声\",\"value\":\"53.1\",\"min_warn\":\"2\",\"max_warn\":\"3\",\"warn_status\":\"0\"},{\"id\":\"137\",\"describe\":\"湿度\",\"value\":\"39.1\",\"min_warn\":\"42\",\"max_warn\":\"43\",\"warn_status\":\"0\"}]}",
      "{\"data\":[]}"];
    ifas[i++] = ["warn_status_delete",
      "http://0.0.0.0:16666/ts/sql/warn_status_delete",
      "{\"version\":\"1.0.0\",\"data\":[{\"id\":\"11\"},{\"id\":\"65\"}]}",
      "{\"data\":[]}"];
    ifas[i++] = ["warn_status_history",
      "http://0.0.0.0:16666/ts/sql/warn_status_history", "",
      "{\"version\":\"1.0.0\",\"data\":[{\"id\":\"11\"},{\"id\":\"65\"}]}",
      "{\"data\":[]}"];
    ifas[i++] = ["log",
      "http://0.0.0.0:16666/ts/shell/log",
      "{\"version\":\"1.0.0\",\"since\":\"2023-04-07 10:33:22\",\"until\":\"2023-04-08 10:33:22\",\"uint\":\"ts.service\"}",
      "{\"version\":\"1.0.0\",\"data\":\"Apr 10 08:08:38 imch systemd-journald: Sumessages from ts.servi\" }"];
    var ifa;
    for (let i = 0; i < ifas.length; i++) {
      ifa = ifas[i];
      text += "<div id=\"" + ifa[0] + "\" class=\"myDiv\">";
      text += "<input id=\"" + ifa[0] + "_url\" type=\"text\" style=\"width:340\" value=\"" + ifa[1] + "\" />";
      text += "<button onclick=\"post('" + ifa[0] + "_')\">" + ifa[0] + "</button><br>";
      text += "<table>";
      text += "<tr>";
      text += "<th>content:</th>";
      text += "<th>standard response:</th>";
      text += "<th>test response:</th>";
      text += "</tr>";
      text += "<tr>";
      text += "<td class=\"td\">";
      text += "<textarea class=\"text\" id=\"" + ifa[0] + "_content\">" + ifa[2];
      text += "</textarea><br/>"
      text += "</td>";
      text += "<td class=\"td\">";
      text += "<textarea class=\"text\" id=\"" + ifa[0] + "_standard_response\">";
      text += ifa[3];
      text += "</textarea><br/>";
      text += "</td>";
      text += "<td class=\"td\">";
      text += "<textarea class=\"text\" id=\"" + ifa[0] + "_response\">";
      text += "no response!";
      text += "</textarea><br/>";
      text += "</td>";
      text += "</tr>";
      text += "</table>";
      text += "</div>";
    }
    document.getElementById("list").innerHTML = text;
	</script>
	<script LANGUAGE="JAVASCRIPT">
		function post(id){
      var url = document.getElementById(id + "url");
      var content = document.getElementById(id + "content");
      var response = document.getElementById(id + "response");
			console.log("url:" + url.value);
			console.log("content:" + content.value);
			var xhttp = new XMLHttpRequest();
			xhttp.open("POST", url.value, false);
			xhttp.setRequestHeader('content-type', 'text/plain');
			xhttp.send(content.value);
			response.value = xhttp.responseText;
			console.log("response:" + xhttp.responseText);
		}
	</script>
</body>

  <!--
  <div id="post_control" class="myDiv" >
    <input id="post_control_url" type="text" style="width:340" value="http://0.0.0.0:16666/ts/mqtt/post_control" />
    <button type="submit" onclick="post('post_control_')">post_control</button><br>
    <table>
      <tr>
        <th>content:</th>
        <th>standard response:</th>
        <th>test response:</th>
      </tr>
      <tr>
        <td class="td">
          <textarea class="text">
        {
          "verison": "1.0.0",
          "table": "gcc",
          "data": [{
            "question": "22",
            "environment": "s22"
          }],
          "method": "post_mqtt"
        }
          </textarea>
        </td>
        <td class="td">
          <textarea class="text">
          standard response!
          </textarea>
        </td>
        <td class="td">
          <textarea class="text">
          no response!
          </textarea><br/>
        </td>
      </tr>
    </table>
  </div>
  -->
  <!--
  -->
